package cn.ruituo.adv8.server;

import java.io.*;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

public class ObjectThread extends Thread {
    private Socket s;
    static Map<String,String> p=new HashMap<>();
    static{
        p.put("clsName","burui");
        p.put("renshu","27人");
        p.put("zuigao","lushen");
        p.put("zuishuai","赵吉山");
        //Penguim.class
    }
    public ObjectThread(Socket s) {
        this.s = s;
    }

    @Override
    public void run() {
        try {
            InputStream in=s.getInputStream();
            OutputStream out=s.getOutputStream();
            ObjectOutputStream oout=new ObjectOutputStream(out);
            ObjectInputStream oin=new ObjectInputStream(in);
            oout.writeObject(p);
            oout.flush();
            System.out.println("发送给"+s+"完毕！");
            Object o=oin.readObject();
            System.out.println(o);
            System.out.println("从"+s+"读到了 "+o);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                s.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
